package com.chsi.onjava8.lambda;

import java.util.function.Predicate;

/**
 * @Auther shikf
 * @Date 2020-04-28 15:35
 */
public class PredicateComposition {
    static Predicate<String>
            p1 = s -> s.contains("bar"),
            p2 = s -> s.length() < 5,
            p3 = s -> s.contains("foo"),
            p4 = p1.negate().and(p2).or(p3);
    public static void main(String[] args) {
        String[] items = {"bar", "foobar", "foobaz", "fongopuckey"};
        for (String item : items) {
            boolean test = p4.test(item);
            System.out.println(item + ":" + test);
        }
    }
}
